package zx.x.modules.yshbms.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;
import zx.x.modules.yshapp.entity.CommunityBulletinEntity;
import zx.x.modules.yshbms.service.CommunityBulletinService;

import java.util.Arrays;
import java.util.Map;


/**
 *社区公告
 */
@RestController
@RequestMapping("yshbms/communitybulletin")
public class CommunityBulletinController {
    @Autowired
    private CommunityBulletinService communityBulletinService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = communityBulletinService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		CommunityBulletinEntity communityBulletinEntity = communityBulletinService.getById(id);

        return R.ok().put("communityBulletinEntity", communityBulletinEntity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CommunityBulletinEntity communityBulletinEntity){
        communityBulletinService.save(communityBulletinEntity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CommunityBulletinEntity communityBulletinEntity){
        communityBulletinService.updateById(communityBulletinEntity);
        return R.ok();
    }


}
